<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text"> <button>打印</button>
    <script>
        let oText = document.getElementsByTagName('input')[0];
        let oBtn = document.getElementsByTagName('button')[0];
        oBtn.onclick = function(){
            console.log(oText.value);
            oText.value = "hello";
        }
    </script>
</body>
</html>